package com.sdcx.agrobank.ui.activity;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.blankj.utilcode.util.SPUtils;
import com.blankj.utilcode.util.ToastUtils;
import com.sdcx.agrobank.R;
import com.sdcx.agrobank.bean.SPBean;
import com.sdcx.agrobank.event.myEvent;
import com.sdcx.agrobank.event.xykEvent;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

public class Main3Activity extends AppCompatActivity {

    private TextView login;
    private TextView phone,pwd;
    private ImageView back;

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onmyEvent(myEvent myEvent) {

    }
    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onMessageEvent(xykEvent myEvent) {

    }
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main3);
        if (!EventBus.getDefault().isRegistered(this)) {
            EventBus.getDefault().register(this);
        }
        login = findViewById(R.id.login);
        back = findViewById(R.id.back);
        back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });
        phone = findViewById(R.id.phone);
        pwd = findViewById(R.id.pwd);
        login.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (phone.getText().toString().equals("17621944290")&&pwd.getText().toString().equals("123456")) {
                   // startActivity(new Intent(Main3Activity.this, Main4Activity.class));
                    EventBus.getDefault().post(new xykEvent());
                    EventBus.getDefault().post(new myEvent());
                    ToastUtils.showLong("登录成功");
                   // SPUtils.getInstance().put("login","1");
                    SPBean.open="1";
                    finish();
                }else {
                    ToastUtils.showLong("登陆失败，请检查您的账号密码");
                }
            }
        });
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        EventBus.getDefault().unregister(this);
    }
}